package com.zhongshan.ga.mobile.tools;

import com.google.gson.JsonObject;
import com.zhongshan.ga.commonvar.ArgsConfig;

/**
 * 
 * json返回结果生成工具
 * 
 * @author Tom
 *
 */
public class JsonResultUtils {
	
	/**
	 * 创建并返回结果json
	 * @param operateCode 操作码
	 * @param resultDesc 结果详情
	 * @param isSuc 结果是否成功
	 * @return
	 */
	public static JsonObject createResultJson(String operateCode, String resultDesc, boolean isSuc) {
		JsonObject resultJson = new JsonObject();
		if (isSuc) {
			resultJson.addProperty(ArgsConfig.RESULT_CODE, ArgsConfig.RESPONSE_SUCCESS);
		} else {
			resultJson.addProperty(ArgsConfig.RESULT_CODE, ArgsConfig.RESPONSE_FAIL);
		}
		resultJson.addProperty(ArgsConfig.OPERATE_CODE, operateCode);
		resultJson.addProperty(ArgsConfig.RESULT_DESC, resultDesc);
		return resultJson;
	}
	
}
